/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hcmus.fit.master.sevensea.control;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

/**
 *
 * @author hvp
 */
public class Score {
   public static List<Bitmap> Resources;
        public int SCORE;

        public Score(int score)
        {
            SCORE = score;
        }

        public void Show(Canvas g, int x, int y)
        {

            List<Integer> list = new ArrayList<Integer>();

            int score = SCORE;
            while (score > 0)
            {
                list.add(new Integer(score % 10));
                score /= 10;
            }
            if (list.size() <= 0)
                list.add(new Integer(0));

            x -= (list.size() * 11 / 2);

            for (int i = 0; i < list.size(); i++)
            {
                int num = ((Integer)list.get(list.size()-i-1)).intValue();
                Bitmap tmp = (Bitmap) Resources.get(num);
                int w = tmp.getWidth();
                g.drawBitmap(tmp, x + i*w, y, new Paint());
            }


        }

        public static List<Bitmap> GetResource(Bitmap resource, int maxX, int maxY, int numerator, int denominator)
        {
            List<Bitmap> rs = new ArrayList<Bitmap>();
            int w = resource.getWidth() / maxX;
            int h = resource.getHeight() / maxY;
           
            for (int i = 0; i < maxY; i++)
            {
                for (int j = 0; j < maxX; j++)
                {
                    Bitmap tmp = Bitmap.createBitmap(resource, j * w, i * h, w, h);                                      
                    rs.add(tmp);
                }
            }
            return rs;
        }
}
